/*-----------------------------------------------------------------------------
Archivo:      test_cu.c
Autor:	      Cesar Armando Fuguet Tortolero
	          Debe compilarse con la herramienta genpat.
------------------------------------------------------------------------------*/

#include <stdio.h>
#include "genpat.h"

char* inttostr(int entier) {
    char* str;
    str = (char *) mbkalloc (32 * sizeof(char));
    sprintf(str,"%d",entier);
    return(str);
}

main() {

    DEF_GENPAT("test_cemisidfft_chip");

    DECLAR("CLK_i"          ,":2","B", IN   ,	      ""      , "");
    DECLAR("RESET_i"        ,":2","B", IN   ,	      ""      , "");
    DECLAR("LOAD_i"         ,":2","B", IN   ,	      ""      , "");
    DECLAR("INIT_ADDRESS_i" ,":2","B", IN   ,	"5 downto 0"  , "");
    DECLAR("VDD"            ,":2","B", IN   ,	      ""      , "");
    DECLAR("VSS"            ,":2","B", IN   ,	      ""      , "");
    DECLAR("C_o"            ,":2","B", OUT  ,	      ""      , "");
    DECLAR("OVF_o"          ,":2","B", OUT  ,	      ""      , "");
    DECLAR("N_o"            ,":2","B", OUT  ,	      ""      , "");
    DECLAR("Z_o"            ,":2","B", OUT  ,	      ""      , "");

    DECLAR("pc_wire",
            ":2",
            "B",
            SIGNAL,
            "5 downto 0",
            "");

    DECLAR("curr_instr_wire",
            ":2",
            "B",
            SIGNAL,
            "11 downto 0",
            "");

    DECLAR("next_instr_wire",
            ":2",
            "B",
            SIGNAL,
            "11 downto 0",
            "");

    DECLAR("pipeline_vrf_a_wire",
            ":2",
            "B",
            SIGNAL,
            "3 downto 0",
            "");

    DECLAR("mux_alu_b_wire",
            ":2",
            "B",
            SIGNAL,
            "3 downto 0",
            "");

    DECLAR("pipeline_alu_wire",
            ":2",
            "B",
            SIGNAL,
            "3 downto 0",
            "");

    DECLAR("alu_out_wire",
            ":2",
            "B",
            SIGNAL,
            "3 downto 0",
            "");

    LABEL("cemisidfft");

    SETTUNIT("ns");
    AFFECT("0", "VDD"	         , "1"         ); 
    AFFECT("0", "VSS"	         , "0"         );
    AFFECT("0", "CLK_i"	         , "0"         );
    AFFECT("0", "RESET_i"        , "1"         );
    AFFECT("0", "LOAD_i"         , "1"         );
    AFFECT("0", "INIT_ADDRESS_i" , "0b000010"  );

    int i;
    for(i=1; i<50; i++) {
        AFFECT("+50"    , "CLK_i"   , inttostr(i%2));

        if(i == 8) {
            AFFECT("+0", "RESET_i", "0");
        }

        if(i == 14) {
            AFFECT("+0", "LOAD_i", "0");
        }
    }

    SAV_GENPAT();

    exit(0);
}

/* vim: tabstop=4 : expandtab : shiftwidth=4
*/
